package com.webmarmun;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public final class SplashTest extends JWindow implements ActionListener {

    private TestTimer testTimer;
    private int duration = 3000;

    public SplashTest(int time) {
        ImageIcon ii = new ImageIcon("splashscreen.jpg");
        JScrollPane jsp = new JScrollPane(new JLabel(ii));
        getContentPane().add(jsp);
        setSize(505, 255);
        centerScreen();
        setVisible(true);
        testTimer = new TestTimer(duration);                     // start him up and leave him running
        testTimer.addActionListener(this);
        testTimer.start();
//        if (time != 0) {
//            try {
//                Thread.sleep(time);
//                if (Thread.currentThread().isAlive()) {
//                } else {
//
//                    dispose();
//                    FirstFrame f = new FirstFrame();
//                    f.setVisible(true);
//                }
//
//
//            } catch (InterruptedException ie) {
//            }
//        }
    }

    private void centerScreen() {
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((d.getWidth() - getWidth()) / 2);
        int y = (int) ((d.getHeight() - getHeight()) / 2);
        setLocation(x, y);
    }

    public static void main(String args[]) {
        SplashTest s = new SplashTest(1000);
        s.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == testTimer) {
            TableFromDatabase f = new TableFromDatabase();
            f.setVisible(true);
            dispose();
            f.setVisible(true);
        }
    }

    private void Counter() {

        TableFromDatabase f = new TableFromDatabase();
        f.setVisible(true);
        dispose();
        f.setVisible(true);



    }
}
